package com.hxkj.controller;

import com.hxkj.domain.po.Article;
import com.hxkj.domain.po.Tags;
import com.hxkj.entity.vo.ArticleVO;
import com.hxkj.service.ArticleService;
import com.hxkj.service.IndexService;
import com.platform.common.domain.result.ResultPageStruct;
import com.platform.common.domain.to.PageTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.Callable;

@RestController
@RequestMapping(value = "/homePage")
public class IndexController {

    @Autowired
    private IndexService indexService;
    @Autowired
    private ArticleService articleService;

    @RequestMapping(value = "/selectArticleForUserCenter")
    public Callable<List<ArticleVO>> selectArticleForUserCenter() throws Exception{
        return () -> indexService.selectArticleForUserCenter();
    }

    @RequestMapping(value = "/modifyHeat", method = RequestMethod.POST)
    public Callable<Article> modifyHeat(@ModelAttribute Article article) throws Exception {
        return () -> articleService.modifyHeat(article);
    }

    /**
     * @author Mr.zheng
     * @Description getHotTagsList 获取热词标签
     * @Date 11:59 2018/7/20
     * @Param [tags]
     * @return java.util.List<com.hxkj.domain.po.Tags>
     **/
    @RequestMapping(value = "/getHotTagsList", method = RequestMethod.POST)
    public Callable<ResultPageStruct<Tags>> getHotTagsList(@ModelAttribute Tags tags, @ModelAttribute PageTo pageParam) throws Exception{
        return () -> articleService.getHotTagsList(tags,pageParam);
    }
}
